﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;

namespace HCQ2_Model.VRQDMeta.InputDto._20220112
{
    /// <summary>
    ///   新增应用
    /// </summary>
    public class InputProgram
    {
        /// <summary>
        ///  用户编码
        /// </summary>
        [Required(ErrorMessage = "用户编码必传！")]
        public string userid { get; set; }
        /// <summary>
        ///  名称
        /// </summary>
        [Required(ErrorMessage = "名称必传！")]
        public string fileName { get; set; }
        /// <summary>
        ///  简介
        /// </summary>
        public string fileNote { get; set; }
        /// <summary>
        ///  最大人数
        /// </summary>
        [Required(ErrorMessage = "最大人数必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入最大人数")]
        public int playerNum { get; set; }
        /// <summary>
        ///  最大时长，数字型，单位：秒【整型】
        /// </summary>
        [Required(ErrorMessage = "最大时长必传！")]
        public int timeSpan { get; set; }
        /// <summary>
        ///  所属目录ID
        /// </summary>
        [Required(ErrorMessage = "所属目录ID必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入所属目录ID")]
        public int folderID { get; set; }
        /// <summary>
        ///  应用ID
        /// </summary>
        [Required(ErrorMessage = "应用ID必传！")]
        public string appID { get; set; }
        /// <summary>
        ///  应用大小，数字型，单位：Kb
        /// </summary>
        [Required(ErrorMessage = "应用大小必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入应用大小")]
        public int appSize { get; set; }
        /// <summary>
        ///  价格明细
        /// </summary>
        [Required(ErrorMessage = "价格明细必传！")]
        public List<PriceMoney> listPrice { get; set; }
        /// <summary>
        /// 转T_DocumentInfo实体
        /// </summary>
        /// <returns></returns>
        public T_DocumentInfo ToEntity()
        {
            return new T_DocumentInfo
            {
                file_name = this.fileName,
                file_note = this.fileNote,
                pag_num = this.playerNum,
                finish_time = this.timeSpan, //(int)(this.timeSpan * 60 * 60),
                store_id = this.folderID,
                attach_url = this.appID,
                file_size = this.appSize,
                file_classify = "",
                doc_type = ""
            };
        }
    }
    /// <summary>
    ///  价格明细
    /// </summary>
    public class PriceMoney
    {
        /// <summary>
        ///  月份【0：表示无期限】
        /// </summary>
        [Required(ErrorMessage = "月份必传！")]
        public int month { get; set; }
        /// <summary>
        ///  金额
        /// </summary>
        [Required(ErrorMessage = "金额必传！")]
        public decimal price { get; set; }
    }
    /// <summary>
    ///  编辑应用
    /// </summary>
    public class InputEditProgram
    {
        /// <summary>
        ///  应用商品id
        /// </summary>
        [Required(ErrorMessage = "应用商品id必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入商品id")]
        public int fileID { get; set; }
        /// <summary>
        ///  应用缩略图地址
        /// </summary>
        public string imageUrl { get; set; }
        /// <summary>
        ///  用户编码
        /// </summary>
        [Required(ErrorMessage = "用户编码必传！")]
        public string userid { get; set; }
        /// <summary>
        ///  名称
        /// </summary>
        [Required(ErrorMessage = "名称必传！")]
        public string fileName { get; set; }
        /// <summary>
        ///  简介
        /// </summary>
        public string fileNote { get; set; }
        /// <summary>
        ///  最大人数
        /// </summary>
        [Required(ErrorMessage = "最大人数必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入最大人数")]
        public int playerNum { get; set; }
        /// <summary>
        ///  所属目录ID
        /// </summary>
        [Required(ErrorMessage = "所属目录ID必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入所属目录ID")]
        public int folderID { get; set; }
        /// <summary>
        ///  价格明细
        /// </summary>
        [Required(ErrorMessage = "价格明细必传！")]
        public List<PriceMoney> listPrice { get; set; }
        /// <summary>
        /// 转T_DocumentInfo实体
        /// </summary>
        /// <returns></returns>
        public T_DocumentInfo ToEntity()
        {
            return new T_DocumentInfo
            {
                file_name = this.fileName,
                file_note = this.fileNote,
                pag_num = this.playerNum,
                image_url = this.imageUrl,
                //finish_time = this.timeSpan, 
                store_id = this.folderID,
                //attach_url = this.appID,
                //file_size = this.appSize,
                file_classify = "",
                doc_type = ""
            };
        }
    }
}